package com.zyp.test.test;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;

public class Main4Activity extends AppCompatActivity implements View.OnTouchListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main4);
        ViewGroup groupA = (ViewGroup) ((ViewGroup) getWindow().getDecorView().findViewById(android.R.id.content)).getChildAt(0);
        View view = findViewById(R.id.button);
        ViewGroup groupB = (ViewGroup) findViewById(R.id.groupB);
        groupA.setOnTouchListener(this);
        view.setOnTouchListener(this);
        groupB.setOnTouchListener(this);
    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {

        switch (v.getId()) {
            case R.id.button:
                Log.d("id", "button");
                break;
            case R.id.groupB:
                Log.d("id", "groupB");
                break;
            default:
                Log.d("id", "view" + v.getId());
                break;
        }
        return false;
    }
}
